/// @tags: DP
#include <cstdio>
#include <iostream>
#define rint register int

using std::cin;
using std::cout;

namespace BlueQuantum {

constexpr int maxn = 1e2 + 3;

char str[maxn];
short sum[maxn][maxn][2];
short f[maxn][maxn][maxn][maxn];

inline void max(short &a, short b) { (a < b) && (a = b); }

inline int main() {
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> (str + 1);
    for (int j = 1; j <= m; ++j) {
      char c = str[j];
      if (c == 'E')
        x = i, y = j;
      else if (c == 'o') {
        sum[i][j][0] = sum[i - 1][j][0] + 1;
        sum[i][j][1] = sum[i][j - 1][1] + 1;
      } else {
        sum[i][j][0] = sum[i - 1][j][0];
        sum[i][j][1] = sum[i][j - 1][1];
      }
    }
  }
  short ans = 0;
  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j) {
      for (int k = 0; k <= n - x; ++k) {
        for (int l = 0; l <= m - y; ++l) {
          max(ans, f[i][j][k][l]);
          if (x - i - 1 > k)
            max(f[i + 1][j][k][l], f[i][j][k][l] + sum[x - i - 1][std::min(m - j, y + l)][1] -
                                       sum[x - i - 1][std::max(y - j - 1, l)][1]);
          if (y - j - 1 > l)
            max(f[i][j + 1][k][l], f[i][j][k][l] + sum[std::min(n - i, x + k)][y - j - 1][0] -
                                       sum[std::max(x - i - 1, k)][y - j - 1][0]);
          if (x + k + 1 <= n - i)
            max(f[i][j][k + 1][l], f[i][j][k][l] + sum[x + k + 1][std::min(m - j, y + l)][1] -
                                       sum[x + k + 1][std::max(y - j - 1, l)][1]);
          if (y + l + 1 <= m - j)
            max(f[i][j][k][l + 1], f[i][j][k][l] + sum[std::min(n - i, x + k)][y + l + 1][0] -
                                       sum[std::max(x - i - 1, k)][y + l + 1][0]);
        }
      }
    }
  }
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("AT2045 [AGC004E] Salvage Robots.in", "r", stdin);
  freopen("AT2045 [AGC004E] Salvage Robots.out", "w", stdout);
#endif
#endif

  std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
